﻿
//TODO:   显示友好信息
function showError(msgType, msgCode, msgContent, extraData) {
    if (extraData)
        alert(extraData + ' : ' + msgContent);
    else
        alert(msgContent);
}

//Server Unhandled Exception
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
function endRequestHandler(sender, args) {
    var error = args.get_error();
    if (error != undefined) {
        var errorMessage;
        if (args.get_response().get_statusCode() == '200') {
            errorMessage = error.message;
            errorMessage = errorMessage.replace(error.name + ":", '');
            //            try 
            //            {
            //           var json = eval("("+errorMessage+")");
            //            errorMessage = json.param + ' : ' + json.message;
            //            }
            //            catch (e)
            //            { 
            //            }
        }
        else {
            // Error occurred somewhere other than the server page.
            errorMessage = 'An unspecified error occurred. ';
        }
        args.set_errorHandled(true);
        alert(errorMessage);
    }
}
